home *** CD-ROM | disk | FTP | other *** search
/ Greenhouse Effect Detection Expriment / NASA Greenhouse Effect Detection Expriment 1992 - Disc 2.iso / software / dos / cdf22pc / src / tools / cdfbrow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-11  |  41.5 KB  |  1,502 lines

  1. /******************************************************************************
  2. *
  3. *  NSSDC/CDF                            CDFbrowse.
  4. *
  5. *  Version 2.0, 9-Mar-92, ST Systems (STX)
  6. *
  7. *  Modification history:
  8. *
  9. *   V1.0  24-Jan-91, D Grogan, H Leckner  Original version (for CDF V2.0).
  10. *   V1.1  30-Jan-91, J Love          Allocated enough space for menu of
  11. *                      attribute entries for a variable.
  12. *   V1.2  26-Mar-91, J Love          Cast menu text pointer to void and
  13. *                      added include of "ctype.h".  Used
  14. *                      toupper the safe way and added a
  15. *                      definition for toupper if SunOS
  16. *                      4.0.3.
  17. *   V1.3   4-Jun-91, S Sudarsan           Improved File/Directory handling
  18. *                                         with file_names.c
  19. *   V1.4  25-Jun-91, J Love          Removed TITLE display unless NSSDC
  20. *                      standard configuration.  Added QOP.
  21. *   V1.5   3-Aug-91, J Love          Cray/UNICOS port.  Use 'Exit' &
  22. *                      'ExitBAD'.  Fixed no-can-do window.
  23. *   V2.0   9-Mar-92, J Love          Modified for IBM-PC port.  CDF V2.2
  24. *             H Leckner
  25. *
  26. ******************************************************************************/
  27.  
  28. #ifdef vms
  29. #include <stdio.h>
  30. #include <descrip.h>
  31. #include <rmsdef.h>
  32. #include <climsgdef.h>
  33. #endif
  34.  
  35. #if defined(unix)
  36. #include <sys/types.h>
  37. #include <sys/stat.h>                        /* V1.3 */
  38. #endif
  39.  
  40. #include <ctype.h>                        /* V1.2 */
  41.  
  42. #include "cdfdist.h"
  43. #include "wfl.h"
  44. #include "kb_def.h"
  45. #include "dynaptr.h"    /* dynamic array macros */
  46. #include "utility.h"
  47.  
  48. #define CDFBROW        /* For global/external variables. */
  49. #include "cdfbrow.h"
  50.  
  51. #if defined(__MSDOS__)
  52. extern unsigned _stklen = 50000U;
  53. #endif
  54.  
  55. #define CLEAN_PAGE(pagePtr,np,string)  {long j;                \
  56.                     for(j=0; j<np; j++)        \
  57.                        strcpy(pagePtr[j],string);    \
  58.                     strcpy(pagePtr[np-1],"");    \
  59.                     }
  60.  
  61.     /* Constants for the screen layout */
  62.  
  63. #define TITLE_ROW    2    /* Title box location */
  64. #define TITLE_COL    2
  65.  
  66. #define HEADER_ROW    4    /* Header box location */
  67. #define HEADER_COL    1
  68.  
  69. #define ATTMEN_ROW    4    /* Attributes menu location and height */
  70. #define ATTMEN_COL    24
  71. #define ATTMEN_HT    8
  72.  
  73. #define VARMEN_ROW    9    /* Variables menu location and height */
  74. #define VARMEN_COL    6
  75. #define VARMEN_HT    8
  76.  
  77.     /* Other constants */
  78.  
  79. #define HIGHLIGHT      1    /* For call to WFL_popup_menu() */
  80. #define HIGHLIGHT_OFF      0
  81.  
  82. #define  BEEP        1    /* For call to MESS_display() */
  83. #define  NOBEEP     0
  84.  
  85. #define HEADER_LINES    SCREEN_HEIGHT
  86. #define TITLE_LINES    6
  87.  
  88. #define VARDEF        1    /* selector for 2 kinds of variable displays */
  89. #define VARVAL         2
  90. #if defined(__MSDOS__)
  91. #define VARVAL_LINES (752)     /* maximum items allowed in varVal display */
  92. #else
  93. #define VARVAL_LINES (5003)
  94. #endif
  95. #define CDF_IS_CLOSED    0
  96.  
  97. #define MAXNAMELEN        512    /* Concerning file_names and dlist() */
  98. #define MAXFILES        2048
  99. #define TRUNC_NONE      " "
  100. #define TRUNC_VER       ";"
  101. #define TRUNC_EXT       "."
  102.  
  103.         /* Defining id's for all menus & forms */
  104.  
  105. #define     selectDirectoryFormId    -1
  106. #define     selectRecordFormId    -2
  107.  
  108. #define     transientMenuId        0
  109. #define     filesMenuId         1
  110. #define     filenotfoundMenuId     2
  111. #define     browseMenuId        3
  112. #define     attrMenuId        4
  113. #define     varMenuId        5
  114. #define     varDefMenuId        6
  115. #define     attrEntriesMenuId    7
  116. #define     mainHelpMenuId        8
  117. #define     showMenuKeysMenuId    9
  118. #define     showFormKeysMenuId    10
  119. #define     helpInContextMenuId    11
  120. #define     generalMenusId        12
  121. #define        generalFormsId        13
  122. #define        varValMenuId        14
  123. #define        attrEntryElemsMenuId    15    /* new menu, v2.0 */
  124. #define        copyrightMenuId        16    /* new menu, v2.0 */
  125. #define        menuMapMenuId        17    /* new menu, v2.0 */
  126.  
  127.     /* the cdf_id is a global variable */
  128.  
  129. static   long        cdf_id = 0;
  130. /******************************************************************************
  131. * BuildSearchSpec.
  132. ******************************************************************************/
  133.  
  134. void BuildSearchSpec (path_spec, search_spec)
  135. char *path_spec;
  136. char *search_spec;
  137. {
  138. strcpy (search_spec, path_spec);
  139.  
  140. if (strlen(search_spec) > 0)
  141.   if (IsDir(search_spec))
  142.     AppendToDir (search_spec, "*.cdf");
  143.   else
  144.     strcat (search_spec, ".cdf");
  145. else
  146.   strcpy (search_spec, "*.cdf");
  147.  
  148. return;
  149. }
  150.  
  151. /******************************************************************************
  152. * BuildWFLlist.
  153. ******************************************************************************/
  154.  
  155. void BuildWFLlist (nlines, lines1, list)
  156. long nlines;
  157. char **lines1;
  158. char ***list;
  159. {
  160. int i;
  161.  
  162. *list = (char **) malloc ((nlines+1) * sizeof(char *));
  163.  
  164. for (i = 0; i < nlines; i++) {
  165.    (*list)[i] = (char *) malloc (strlen(lines1[i]) + 1);
  166.    strcpy ((*list)[i], lines1[i]);
  167. }
  168.  
  169. (*list)[i] = (char *) malloc ((size_t) 1);
  170. strcpy ((*list)[i], "");
  171.  
  172. return;
  173. }
  174.  
  175. /******************************************************************************
  176. * FreeWFLlist.
  177. ******************************************************************************/
  178.  
  179. void FreeWFLlist (list)
  180. char **list;
  181. {
  182. int i;
  183.  
  184. for (i = 0; /*no-terminator*/; i++) {
  185.    if (list[i][0] == '\0') {        /* Null-string ends WFL list. */
  186.      free (list[i]);
  187.      free (list);
  188.      return;
  189.    }
  190.    else
  191.      free (list[i]);
  192. }
  193. }
  194.  
  195. void exitProgram ()
  196. {
  197.     /* If it is open, close the CDF.
  198.      * cdf_id is static global variable.
  199.      */
  200.    if (cdf_id != CDF_IS_CLOSED) cdfCloseQuit ();
  201.  
  202.     /* Close the interface package */
  203.    WFL_close ();
  204.    Exit;
  205. }  /* end exitProgram */
  206.  
  207.  
  208. int interrupt_check (keyWas, menu_id)
  209. int keyWas;
  210. int menu_id;
  211. {
  212.     /* This function should be called after every return
  213.      * from a menu or a form to see if the user has
  214.      * struck one of the interrupt keys --
  215.      *    HELP
  216.      *    CONTEXT_HELP
  217.      *    QUIT (the program EXIT command)
  218.      */
  219.  
  220.     int saveRow;
  221.     int saveCol;
  222.     static char YesNo[4] = "No";
  223.  
  224.     /* Save location of cursor from last menu or form */
  225.     saveRow = menu_bar_last_at_row (0);
  226.     saveCol = menu_bar_last_at_col (0);
  227.  
  228.     switch (keyWas)    {
  229.     case KBM_HELP:
  230.          helpMenu (menu_id);
  231.          break;
  232.  
  233.     case KB_CONTEXT_HELP:
  234.          explain (saveRow+2, saveCol+2, menu_id);
  235.          break;
  236.  
  237.     case KBM_QUIT:
  238.          GENERIC_form (" EXIT the program (Y/N) ? ",
  239.                         YesNo, 3, 0, 0);
  240.          if ((islower(YesNo[0]) ?
  241.             toupper(YesNo[0]) : YesNo[0]) == 'Y')    /* V1.2 */
  242.         exitProgram ();
  243.          break;
  244.     default:
  245.          break;
  246.     }
  247.  
  248.     /* restore location of cursor as it was on function entry. */
  249.     menu_bar_last_at_row (saveRow);
  250.     menu_bar_last_at_col (saveCol);
  251.  
  252.     return;
  253.  
  254. }  /* end interrupt_check */
  255.  
  256.  
  257. int explain (row, col, menu_id)
  258. int row;
  259. int col;
  260. int menu_id;
  261. {
  262.      long int selection;
  263.      static char *explainGeneralMenus[] =
  264.     {
  265.     "                            -- Menus -- ",
  266.     " ",
  267.     " Menus are windows containing selection lists. ",
  268.     " A reverse-video bar will show you the current selection ",
  269.     " in a menu.  Use the UP and DOWN arrow keys to move the ",
  270.     " menu bar.  To move the bar full menu \"pages\" press the ",
  271.     " PAGE-DOWN (D) and the PAGE-UP (U) keys. ",
  272.     " Press the SELECT (RETURN) key to choose a menu item.",
  273.     " When you want to leave a menu, use the KILL key (CTRL-K). ",
  274.     "    (See also \"Menu Keys\" in the main help menu.) ",
  275.     " ",
  276.     " Special Note:  Some windows do NOT have reverse-video bars. ",
  277.     " These are information windows and there is nothing to select ",
  278.     " from them.  However, they may sometimes contain multiple pages ",
  279.     " of information.  The window message will tell you when this ",
  280.     " is the case.  For example, the window may say \"12 Attributes\" ",
  281.     " when only 8 are displayed. ",
  282.     " Or, you might see \" -- more -- \" as you do in this window. ",
  283.     " In these situations, strike the PAGE-DOWN key (D) TWICE to ",
  284.     " to see more of the window, and continue striking the PAGE-DOWN key ",
  285.     " until you reach the end of an information window. ",
  286.     "                             -- more -- ",
  287.     " ",
  288.     " This demonstrates the use of the PAGE-DOWN key to see more. ",
  289.     " To go back up, press PAGE-UP (U) twice.",
  290.     " ",
  291.     " (This is the end of information about Menus.  CTRL-K to quit.) ",
  292.     " ",
  293.     "",
  294.     };
  295.  
  296.      static char *explainGeneralForms[] =
  297.     {
  298.     "                            -- Forms -- ",
  299.     " ",
  300.     " Forms are for your input of data, often just one item. ",
  301.     " ",
  302.     " Forms will have one or more fields for data entry. ",
  303.     " The prompt for a field will describe what is needed. ",
  304.     " Just type normally in the form field. ",
  305.     " Press the RETURN key to SELECT (or accept) the item. ",
  306.     " ",
  307.     " Be sure to see the main help selection named \"Form Keys\", ",
  308.     " especially the line-editing section, for more help with forms. ",
  309.     " ",
  310.     "",
  311.     };
  312.  
  313.      static char *explainDirNameForm[] =
  314.     {
  315.     "              -- Browse Directory Prompt -- ",
  316.     " ",
  317.     " Enter any legal VMS directory path specification in this ",
  318.     " one-item input form and press RETURN. ",
  319.     " ",
  320.     " You may include a CDF name, or partial name, in the path ",
  321.     " if you wish to see only certain CDFs.    ",
  322.     " CDFbrowse will append \"*.cdf\" to the name you give and ",
  323.     " search the named directory for *.cdf type files. ",
  324.     " Therefore, if the name you specify is a VMS logical-name, ",
  325.     " end the name with a colon, as in \"LOGICAL_PATH:\"  .",
  326.     " ",
  327.     " If there are CDFs on the directory, you will see ",
  328.     " the CDFs Menu containing a list of those CDFs. ",
  329.     " ",
  330.     " Examples:",
  331.     "    ncf_cdaw_user:[cdaw8cdf.eventa] ",
  332.     "    [] ",
  333.     "    logical_path: ",
  334.     "    []cac_sst_blended" ,
  335.     " ",
  336.     "                                          (CTRL-K to quit.) ",
  337.     "",
  338.     };
  339.  
  340.      static char *explainRecordNumForm[] =
  341.     {
  342.     "              -- CDF Record Number Prompt -- ",
  343.     " ",
  344.     " You will see this prompt after selecting a variable in the ",
  345.     " Variable Values Menu.",
  346.     " ",
  347.     " Enter an integer from 1 to the number of records in the CDF ",
  348.     " and press RETURN. ",
  349.     " ",
  350.     " You will then see the values of the current variable for ",
  351.     " for that record displayed in an information window.",
  352.     " ",
  353.     "                                          (CTRL-K to quit.) ",
  354.     "",
  355.     };
  356.  
  357.      static char *explainFileMenu[] =
  358.     {
  359.     "                    -- CDFs Menu -- ",
  360.     " ",
  361.     " The CDFs Menu shows you the names of the CDFs on the ",
  362.     " directory you selected in the opening 'Browse Directory' prompt.",
  363.     " ",
  364.     " Select a CDF from the menu.  First, the CDF header ",
  365.     " will be displayed, and then the Browser Menu will appear. ",
  366.     " ",
  367.     "",
  368.     };
  369.  
  370.      static char *explainBrowserMenu[]=
  371.     {
  372.     "                   -- Browser Menu -- ",
  373.     " ",
  374.     " You'll see this menu after selecting a CDF from the CDFs Menu.",
  375.     " ",
  376.     " Choose an item on the Browser to go to other menus for ",
  377.     " more information about the current CDF. ",
  378.     " For instance, choose \"Attribute Definitions\" to go to ",
  379.     " the Attributes Menu. ",
  380.     " ",
  381.     "",
  382.     };
  383.  
  384.      static char *explainAttrMenu[] =
  385.     {
  386.     "                   -- Attributes Menu -- ",
  387.     " ",
  388.     " Here you see all the attributes defined for the current CDF. ",
  389.     " You will see each attribute's name, number of entries, and scope. ",
  390.     " ",
  391.         " Select an attribute to see all the entries for that attribute. ",
  392.         " ",
  393.     "",
  394.     };
  395.  
  396.      static char *explainVarOfAttMenu[] =
  397.     {
  398.     "                       -- Entries Menu -- ",
  399.     " ",
  400.     " You'll see this menu after selecting from the Attribute Menu. ",
  401.     " ",
  402.         " In this menu, all entries of the chosen attribute are shown. ",
  403.     " If the attribute is global in scope you'll see {global}, ",
  404.     " otherwise the name of the variable to which it refers is shown.",
  405.     " You will also see each entry's datatype and its number of elements, ",
  406.     " followed by the content of the first element.  (If it's a string, ",
  407.     " you'll see all of it that can fit the screen.)  If more elements ",
  408.     " exist, not shown, you'll see {...} at the end. ",
  409.     " ",
  410.     " Select an entry to see all the additional elements, or to see a ",
  411.     " string-type entry displayed vertically, character-by-character.",
  412.     " ",
  413.     "",
  414.     };
  415.  
  416.      static char *explainElementsMenu[] =
  417.     {
  418.     "                       -- Elements List -- ",
  419.     " ",
  420.     " You'll get to this list from one of two places, either from the ",
  421.     " Entries Menu for attributes, or from the Variable's Entry's Menu. ",
  422.     " ", 
  423.     " This list shows all the elements of an attribute entry in a ", 
  424.     " vertical format.  The first line tells whether the entry is global ",
  425.     " or variable in scope, and tells the datatype. ",
  426.     " Then the elements for the entry are listed. ",
  427.     " ",
  428.     " There is nothing to select from this listing. ",
  429.     " ",
  430.         "",
  431.     };
  432.  
  433.      static char *explainVarMenu[] =
  434.     {
  435.     "                       -- Variables Menu -- ",
  436.     " ",
  437.     " This menu shows you the variables defined for the current CDF. ",
  438.     " ",
  439.         " Select a variable from this menu to see EITHER the values of ",
  440.       " that variable's attributes (the Variable Definition), or ",
  441.     " the actual data values of the variable (Variable Values). ",
  442.     " ",
  443.     " Which of these you see depends on what you chose in the ",
  444.     " Browser Menu -- Variable Definitions or Variable Values.",
  445.     " ",
  446.     "",
  447.     };
  448.  
  449.      static char *explainAttOfVarMenu[] =
  450.     {
  451.     "                  -- Attributes of a Variable -- ",
  452.     " ",
  453.     " You'll see this menu after selecting a variable from the Variable ",
  454.     " Definitions Menu.  ",
  455.     " ",
  456.     " Here, all entries are shown for the attributes of a given variable. ",
  457.     " You will also see each entry's datatype and its number of elements, ",
  458.     " followed by the content of the first element.  (If it's a string, ",
  459.     " you'll see all of it that can fit the screen.)  If more elements ",
  460.     " exist, not shown, you'll see {...} at the end. ",
  461.     " ",
  462.     " Select an entry to see all the additional elements, or to see a ",
  463.     " string-type entry displayed vertically, character-by-character.",
  464.     " ",
  465.     "",
  466.     };
  467.  
  468.  
  469.      static char *explainVarValMenu[]=
  470.     {
  471.     "                  -- Values of a Variable -- ",
  472.     " ",
  473.         " In this listing, data values are shown for the selected variable ", 
  474.     " for the record chosen at the Record Number Prompt. The format of ",
  475.     " the listing will look something like this example:",
  476.     " ",
  477.     "    ( 50)  203:[  2,  7]= datum-value ",
  478.     " ",
  479.      " The number in parentheses, (50), is the item count, which tells you ",
  480.         " where you are in the displayed list.  The next number, which is  ",
  481.     " followed by a colon, 203:, is the CDF record number.  The numbers ",
  482.     " in brackets, [  2,  7], are indexes to dimensions for the CDF. ",
  483.     " ",
  484.     " If you see an asterisk in place of a record or dimension index ",
  485.     " number, it is because the variance is false for the record or ",
  486.     " for the dimension.  For example,   ",
  487.     " ",
  488.     "    ( 50)    *:[  *,  7]= datum-value ",
  489.     " ",
  490.     "                                    <more... PAGE-DOWN (D) twice> ",
  491.     " ",
  492.     " ",
  493.     " The order of indexes in the listing will correspond to the ",
  494.     " storage for of the CDF, either ROW_MAJOR or COL_MAJOR.  ",
  495.     " ",
  496.        " If a \"FORMAT\" attribute exists for the variable, the FORMAT string ",
  497.     " is used to format values. ",
  498.     " ",
  499.       " If the variable is an \"EPOCH\" it will be shown not as a real-number ",
  500.     " but translated to a readable form, like \"03-Dec-1990 11:25:07.000\"",
  501.     " ",
  502.        " At present, no more than 5000 lines will be displayed for a variable. ",
  503.     " ",
  504.     " The Values of a Variable listing is not a selection menu. ",
  505.     " Use PAGE-DOWN and PAGE-UP keys to view long lists. ",
  506.     " ",
  507.     "                                         (CTRL-K to quit this window)",
  508.     " ",
  509.     "",
  510.     };
  511.  
  512.      static char *explainNope[]=
  513.     {
  514.     " ",
  515.         " Sorry, there is no further explanation for the current window. ",
  516.     " ",
  517.     "",
  518.     };
  519.  
  520.     int saveRow, saveCol;
  521.     int keyWas;
  522.     void *menu_ptr;
  523.  
  524.     switch (menu_id)
  525.         {
  526.         case generalMenusId:
  527.                 menu_ptr =
  528.                    (void *) explainGeneralMenus;  /* V1.2 */
  529.                 break;
  530.  
  531.         case generalFormsId:
  532.                 menu_ptr =
  533.                    (void *) explainGeneralForms;  /* V1.2 */
  534.                 break;
  535.  
  536.         case selectDirectoryFormId:
  537.                 menu_ptr =
  538.                    (void *) explainDirNameForm;  /* V1.2 */
  539.                 break;
  540.  
  541.         case filesMenuId:
  542.                 menu_ptr =
  543.                    (void *) explainFileMenu;  /* V1.2 */
  544.                 break;
  545.  
  546.         case browseMenuId:
  547.                 menu_ptr =
  548.                    (void *) explainBrowserMenu;  /* V1.2 */
  549.                 break;
  550.  
  551.         case attrMenuId:
  552.                 menu_ptr =
  553.                    (void *) explainAttrMenu;  /* V1.2 */
  554.                 break;
  555.  
  556.         case varMenuId:
  557.                 menu_ptr =
  558.                    (void *) explainVarMenu;  /* V1.2 */
  559.                 break;
  560.  
  561.         case varDefMenuId:
  562.                 menu_ptr =
  563.                    (void *) explainAttOfVarMenu;  /* V1.2 */
  564.                 break;
  565.  
  566.         case attrEntriesMenuId:
  567.                 menu_ptr =
  568.                    (void *) explainVarOfAttMenu;  /* V1.2 */
  569.                 break;
  570.  
  571.         case varValMenuId:
  572.                 menu_ptr =
  573.                    (void *) explainVarValMenu;  /* V1.2 */
  574.                 break;
  575.  
  576.         case selectRecordFormId:
  577.                 menu_ptr =
  578.                    (void *) explainRecordNumForm;  /* V1.2 */
  579.                 break;
  580.  
  581.         case attrEntryElemsMenuId:
  582.                 menu_ptr =
  583.                    (void *) explainElementsMenu;  /* V1.2 */
  584.                 break;
  585.  
  586.         default:
  587.                 menu_ptr =
  588.                    (void *) explainNope;  /* V1.2 */
  589.                 break;
  590.         } /* end switch */
  591.  
  592.     /* restore saved cursor position */
  593.     saveRow = menu_bar_last_at_row (0);
  594.     saveCol = menu_bar_last_at_col (0);
  595.  
  596.     do /* until keyWas == EXIT */
  597.        {
  598.        keyWas =
  599.         WFL_popup_menu (row, col, SCREEN_HEIGHT,
  600.                 " Explanation ",
  601.                 menu_ptr,
  602.                 &selection, helpInContextMenuId,
  603.                 HIGHLIGHT_OFF);
  604.  
  605.         /* Only check interrupt for the QUIT, not HELP or
  606.          * Context-Help, because the help on help
  607.          * may lead to unchecked recursion.
  608.          */
  609.        if (keyWas == KBM_QUIT)
  610.           interrupt_check (keyWas, helpInContextMenuId);
  611.        }
  612.        while (keyWas != KBM_EXIT);
  613.  
  614.         /* restore saved cursor position */
  615.     menu_bar_last_at_row (saveRow);
  616.     menu_bar_last_at_col (saveCol);
  617.  
  618.     return (keyWas);
  619.  
  620. }  /* end explain */
  621.  
  622.  
  623. void copyrightMenu( row, col)
  624. int row;
  625. int col;
  626. {
  627.    char         **menuText;
  628.    int keyWas;
  629.    long int    selection;
  630.    int pageLines = SCREEN_HEIGHT+3;
  631.  
  632. static char banner[] = "  Documentary text in CDF header  ";
  633.  
  634.    menuText = PTR_LIST_MALLOC( pageLines, char);
  635.    FIXARRAY_MALLOC( menuText, pageLines, char, SCREEN_WIDTH +3);
  636.    CLEAN_PAGE( menuText, pageLines, "");
  637.  
  638.    if (cdf_id == CDF_IS_CLOSED) {
  639.     strcpy( menuText[0],
  640.     "  Please open a CDF first to read the documentary text.  ");
  641.    } else {
  642.     writemCopyright( menuText);
  643.    }
  644.  
  645.    keyWas = KBM_EXIT +1;
  646.    while (keyWas != KBM_EXIT)  {
  647.       keyWas = WFL_popup_menu (row, col, SCREEN_HEIGHT,
  648.                 banner, menuText,
  649.                 &selection, copyrightMenuId,
  650.                 HIGHLIGHT_OFF);
  651.     /* no interrupt check */
  652.    } /* end while */
  653.  
  654.    PTR_LIST_FREE( menuText, pageLines);
  655. }  /* end copyrightMenu */
  656.  
  657.  
  658. void menuMapMenu( row, col)
  659. int row;
  660. int col;
  661. {
  662. static char         *menuText[] = {
  663. " ",
  664. "                        Browse directory prompt",
  665. "                                   |",
  666. "                        CDF Menu (list of CDFs)",
  667. "                                   |",
  668. "        ----------------------Browse Menu------------------------",
  669. "        |                          |                            | ",
  670. " Attribute Menu         Variable Definitions Menu      Variable Values Menu   ",
  671. "        |                          |                            | ",
  672. "  Entries Menu           Variable's Entries Menu       Enter Record (Prompt) ",
  673. "        |                          |                            | ",
  674. " Elements List               Elements List            Variable's Values List ",
  675. " ",
  676. "",
  677. };
  678.    int keyWas;
  679.    long int selection;
  680. static char banner[] = "  Map of CDFbrowse menu structure  ";
  681.  
  682.    keyWas = KBM_EXIT +1;
  683.    while (keyWas != KBM_EXIT)  {
  684.       keyWas = WFL_popup_menu (row, col,
  685.                 SCREEN_HEIGHT,
  686.                 banner, menuText,
  687.                 &selection, menuMapMenuId,
  688.                 HIGHLIGHT_OFF);
  689.     /* no interrupt check */
  690.    } /* end while */
  691. }  /* end menumapMenu */
  692.  
  693.  
  694. int showMenuKeys (row, col)
  695. int row;
  696. int col;
  697. {
  698.      long int selection;
  699.      static char *menuKeys[] =
  700.     {
  701.     " ",
  702.     "  -- function --                                 -- key to use -- ",
  703.     " KILL the current menu  - - - - - - - - - - - -  CTRL-K ",
  704.     " Call the main HELP menu  - - - - - - - - - - -  CTRL-L ",
  705.     " Get HELP-in-context for the current menu - - -  CTRL-I ",
  706.     " SELECT the item marked by the menu bar - - - -  RETURN (Enter) ",
  707.     "  ",
  708.         " EXIT the whole program (go back to VMS)  - - -  CTRL-E ",
  709.     " ",
  710.     " Move menu bar one LINE UP  - - - - - - - - - -  Up arrow ",
  711.         " Move menu bar one LINE DOWN  - - - - - - - - -  Down arrow ",
  712.         "   Note: With the arrows, you can wrap-around ",
  713.         "   from top-to-bottom of the menu list and vice-versa. ",
  714.     "  ",
  715.     " Move menu bar one full menu PAGE UP  - - - - -  U or Key-Pad 7 ",
  716.         " Move menu bar one full menu PAGE DOWN  - - - -  D or Key-Pad 4",
  717.     "   Note: Use these keys when there are more items in ",
  718.     "   a menu than will fit in one window.  On the first ",
  719.     "   strike of either of the PAGE keys the menu bar will move ",
  720.     "   to the top or bottom of the window.  Subsequent strikes ",
  721.         "   of the same key will show you different pages of the menu ", 
  722.     "   list, stopping when you reach the menu-top or -bottom. ",
  723.         "",
  724.     };
  725.  
  726.     int keyWas;
  727.  
  728.     do /* until keyWas == EXIT */
  729.             {
  730.        keyWas =
  731.         WFL_popup_menu (row, col, SCREEN_HEIGHT,
  732.                 " menu keys ", menuKeys,
  733.                 &selection, showMenuKeysMenuId,
  734.                 HIGHLIGHT_OFF);
  735.        }
  736.        while (keyWas != KBM_EXIT);
  737.  
  738.         return (keyWas);
  739.  
  740. }  /* end showMenuKeys  */
  741.  
  742.  
  743.  
  744. int showFormKeys (row, col)
  745. int row;
  746. int col;
  747. {
  748.      long int selection;
  749.      static char *formKeys[] =
  750.     {
  751.     " ",
  752.     "  -- function --                                 -- key to use -- ",
  753.     " KILL the current form  - - - - - - - - - - - -  CTRL-K ",
  754.     " Call the main HELP menu  - - - - - - - - - - -  CTRL-L ",
  755.     " Get HELP-in-context for the current form - - -  CTRL-I ",
  756.     " SELECT (accept) the current item as input and ",
  757.     "   move to NEXT input field (if applicable), or,  ",
  758.     "   SELECT-and-QUIT (in one-item prompt-forms) -  RETURN (Enter) ",
  759.     " ",
  760.     " Move to NEXT field (same as SELECT)  - - - - -  Down-arrow or RETURN ",
  761.     " Move to PREVIOUS field - - - - - - - - - - - -  Up-arrow or CTRL-H ",
  762.     " ",
  763.     " EXIT the whole program (go back to VMS)  - - -  CTRL-E ",
  764.     " ",
  765.     "                   <more>   (press D TWICE) ",
  766.     " ",
  767.     "                     -- Line editing keys --",
  768.     " ",
  769.     " Move cursor LEFT and RIGHT in the line - - - -  Left/Right arrows ",
  770.     " Move cursor to BEGINning of line - - - - - - -  CTRL-B or Key-Pad 8 ",
  771.     " Move cursor to END of line   - - - - - - - - -  CTRL-N or Key-Pad 9 ",
  772.     " ",
  773.     " DELETE one character left of cursor  - - - - -  Delete (Rubout) ",
  774.     " DELETE LEFT of cursor to start of line - - - -  CTRL-X ",
  775.     " DELETE from cursor to end-line inclusive - - -  CTRL-D ",
  776.     " ",
  777.     " Toggle between INSERT and OVERWRITE modes  - -  CTRL-A ",
  778.     "   Note: When the program begins OVERWRITE mode is in effect.  ",
  779.     "   Use INSERT mode to insert text between characters in a line. ",
  780.     "",
  781.     };
  782.  
  783.     int keyWas;
  784.  
  785.     do /* until keyWas == EXIT */
  786.        {
  787.        keyWas =
  788.         WFL_popup_menu (row, col, 15,
  789.                 " form keys ", formKeys,
  790.                 &selection, showFormKeysMenuId,
  791.                 HIGHLIGHT_OFF);
  792.        }
  793.        while (keyWas != KBM_EXIT);
  794.  
  795.     return (keyWas);
  796.  
  797. }  /* end showFormKeys  */
  798.  
  799.  
  800. int helpMenu ( menu_id)
  801. int menu_id;
  802. {
  803.    enum menuTrigger { CURRENT, MENU_GEN, MENU_KEYS, FORM_GEN, FORM_KEYS,
  804.             COPYRIGHT, MENU_MAP };
  805.     /* enum order above must match the menu text below */
  806.    static char *mainHelp[] =
  807.     {
  808.     " Explain the current menu or form ",
  809.     " Explain menus in general ",
  810.     "   Show menu keys usage ",
  811.     " Explain input forms in general ",
  812.     "   Show form keys usage ",
  813.     " Show documentary text in CDF v. 2+ header ",
  814.     " Show a map of CDFbrowse's menu structure ",
  815.     "",
  816.     };
  817.  
  818.    int keyWas;
  819.    long selection;
  820.  
  821.    keyWas = KBM_EXIT +1;
  822.  
  823.    while (keyWas != KBM_EXIT)  {
  824.       keyWas = WFL_popup_menu (1, 1,
  825.                 SCREEN_HEIGHT,
  826.                 " main help ", mainHelp,
  827.                 &selection, mainHelpMenuId,
  828.                 HIGHLIGHT);
  829.  
  830.      /* Only check interrupt for the QUIT, not HELP or
  831.       * Context-Help, because the help on help
  832.       * may lead to unchecked recursion.
  833.       */
  834.       if (keyWas == KBM_QUIT)
  835.      interrupt_check ( keyWas, mainHelpMenuId);
  836.  
  837.       if (keyWas == KBM_SELECT)    {
  838.     switch (selection)  {
  839.         case CURRENT:  /* explain current item */
  840.              explain (  menu_bar_last_at_row (0) +2,
  841.                 menu_bar_last_at_col (0) +2,
  842.                 menu_id);
  843.              break;
  844.  
  845.         case MENU_GEN:  /* explain menus in general  */
  846.              explain (1, 1, generalMenusId);
  847.                  break;
  848.  
  849.          case MENU_KEYS:  /* menu keys */
  850.              showMenuKeys (1, 1);
  851.                  break;
  852.  
  853.         case FORM_GEN:  /* explain forms in general  */
  854.              explain (1, 1, generalFormsId);
  855.              break;
  856.  
  857.         case FORM_KEYS:  /* form keys */
  858.              showFormKeys (1, 1);
  859.              break;
  860.  
  861.         case COPYRIGHT:  /* show copyright notice */
  862.              copyrightMenu( 1, 1);
  863.              break;
  864.  
  865.         case MENU_MAP:
  866.              menuMapMenu( 1, 1);
  867.              break;
  868.  
  869.         }  /* end switch */
  870.     } /* end if SELECT */
  871.      }  /* end while keyWas != EXIT */
  872.  
  873.    return;
  874.  
  875. } /* end helpMenu */
  876.  
  877.  
  878.  
  879.  
  880. int select_directory (path_spec)
  881. char            *path_spec;
  882. {
  883.    /*
  884.     *  Select the directory for browsing, return the string in
  885.     *  path_spec.  Invoke help for the form if requested.
  886.     */
  887.    int keyWas;
  888.    /*int k;*/
  889.  
  890.      do   /* until EXIT or NEXTFIELD (SELECT) */
  891.       {
  892.       keyWas = GENERIC_form ("Browse directory: ",
  893.                 path_spec, 50, 0, 0);
  894.  
  895.       interrupt_check (keyWas, selectDirectoryFormId);
  896.       }
  897.       while ( (keyWas != KBF_NEXTFIELD) && (keyWas != KBF_EXIT) );
  898.  
  899.    return (keyWas);
  900.  
  901. } /* end select_directory */
  902.  
  903.  
  904. void attrEntryElemsMenu(row, col, attrNum, entryNum)
  905. int   row;
  906. int   col;
  907. long  attrNum;
  908. long  entryNum;
  909. {
  910.    char         **menuText;
  911. static char name[CDF_ATTR_NAME_LEN+1] = "no-name";
  912.    char label[CDF_ATTR_NAME_LEN +SCREEN_WIDTH+1];
  913.    int keyWas;
  914.    long selection;
  915.    /*int j,k;*/
  916.    long pageLines = numElemsAttr( attrNum, entryNum)+5;
  917.  
  918.    menuText = PTR_LIST_MALLOC( pageLines, char);
  919.    FIXARRAY_MALLOC( menuText, pageLines, char, SCREEN_WIDTH);
  920.    CLEAN_PAGE( menuText, pageLines, "");
  921.  
  922.     /* load the menuText; all elements this entry, this attr vertically */
  923.    writemAttrElems( menuText, attrNum, entryNum);
  924.  
  925.    attribName( attrNum, name);
  926.    sprintf (label, "  %ld Elements for Entry %ld, Attribute %s  ",
  927.         numElemsAttr( attrNum, entryNum), entryNum+1, name);
  928.  
  929.    keyWas = KBM_EXIT +1;
  930.    while (keyWas != KBM_EXIT)  {
  931.     keyWas = WFL_popup_menu (row, col,
  932.                 SCREEN_HEIGHT, label, menuText,
  933.                 &selection, attrEntryElemsMenuId,
  934.                 HIGHLIGHT_OFF);
  935.     interrupt_check (keyWas, attrEntryElemsMenuId);
  936.    }
  937.    PTR_LIST_FREE( menuText, pageLines);
  938. } /* end attrEntryElemsMenu */
  939.  
  940.  
  941. void varDefMenu (row, col, varNum)
  942. int   row;
  943. int   col;
  944. long  varNum;
  945. {
  946.    char         **menuText;
  947. static char name[CDF_VAR_NAME_LEN+1] = "no-name";
  948.    char label[CDF_VAR_NAME_LEN +SCREEN_WIDTH+1];
  949.    int keyWas /*,j,k*/ ;
  950.    long selection;
  951.    /*** long pageLines = numVars() +5; ***/            /* V1.1 */
  952.    long pageLines = numAttrs() + 5;                /* V1.1 */
  953.  
  954.    menuText = PTR_LIST_MALLOC( pageLines, char);
  955.    FIXARRAY_MALLOC( menuText, pageLines, char, SCREEN_WIDTH);
  956.    CLEAN_PAGE( menuText, pageLines, "");
  957.  
  958.     /* load the menuText */
  959.    writemVarDef( menuText, varNum);
  960.  
  961.    varName(varNum, name);
  962.    sprintf( label,  "  Attributes of Variable %s  ", name);
  963.    keyWas = KBM_EXIT +1;
  964.    while (keyWas != KBM_EXIT)     {
  965.     keyWas = WFL_popup_menu (row, col, SCREEN_HEIGHT,
  966.                 label, menuText,
  967.                 &selection, varDefMenuId,
  968.                 HIGHLIGHT);
  969.     interrupt_check (keyWas, varDefMenuId);
  970.  
  971.     if (keyWas == KBM_SELECT && numAttrs() > 0)  {
  972.         /* adjust the selection for just the numVarAttrs() */
  973.         long adjustedSelection = nthVarAttr( selection);
  974.         if (adjustedSelection > 0)   {  /* then it's OK to display */
  975.             attrEntryElemsMenu( menu_bar_last_at_row (0) +1,
  976.                         menu_bar_last_at_col (0) +1,
  977.                         adjustedSelection, varNum);
  978.         }
  979.     }
  980.    }
  981.    PTR_LIST_FREE( menuText, pageLines);
  982. } /* end varDefMenu */
  983.  
  984.  
  985. void varValMenu(row, col, varNum, max_values)
  986. int   row;
  987. int   col;
  988. long  varNum;
  989. long  max_values;
  990. {
  991.    char         **menuText;
  992. static char name[CDF_VAR_NAME_LEN+1] = "no-name";
  993.    int keyWas /*, j, k*/ ;
  994.    long selection;
  995.    long pageLines = VARVAL_LINES+1;
  996.  
  997.    char label[CDF_VAR_NAME_LEN +SCREEN_WIDTH+1];
  998.    char prompt[CDF_VAR_NAME_LEN +SCREEN_WIDTH+1];
  999.    static char recNumStr[128]="1";
  1000.    long recNum;
  1001. /*
  1002. Only malloc what we need
  1003. */
  1004.    if(max_values < pageLines)pageLines = max_values+4;
  1005.    varName(varNum, name);
  1006.    sprintf(prompt,  "  (%s)  Enter record number: ", name);
  1007.    menuText = PTR_LIST_MALLOC( pageLines, char);
  1008.    FIXARRAY_MALLOC( menuText, pageLines, char,SCREEN_WIDTH +CDF_VAR_NAME_LEN+1);
  1009.    CLEAN_PAGE( menuText, pageLines, "");
  1010.  
  1011.    row = menu_bar_last_at_row (0) +2;
  1012.    col = menu_bar_last_at_col (0) +23;
  1013.  
  1014.    for (;;)  {     /*  FOREVER -- Exit is via KBF_EXIT at the 'Record' prompt */
  1015.     do  {  /* until Form EXIT or NEXTFIELD (SELECT) */
  1016.         keyWas = GENERIC_form (prompt,
  1017.                      recNumStr, 20, row, col-10);
  1018.         sscanf(recNumStr, "%ld", &recNum);
  1019.         interrupt_check (keyWas, selectRecordFormId);
  1020.  
  1021.     } while ( (keyWas != KBF_NEXTFIELD) && (keyWas != KBF_EXIT) );
  1022.  
  1023.         /*  HERE IS THE ONLY NORMAL RETURN POSSIBLE */
  1024.     if (keyWas == KBF_EXIT)
  1025.         {
  1026.         PTR_LIST_FREE( menuText, pageLines);
  1027.         return;
  1028.         }
  1029.  
  1030.     CLEAN_PAGE( menuText, pageLines, "");
  1031.         /* load the menuList */
  1032.     writemVarVals( menuText, varNum, recNum-1, pageLines);
  1033.  
  1034.     sprintf (label, " Values of the Variable %s ", name);
  1035.     keyWas = KBM_EXIT +1;
  1036.     while (keyWas != KBM_EXIT)     {
  1037.         keyWas = WFL_popup_menu (row, col, SCREEN_HEIGHT,
  1038.                 label, menuText,
  1039.                 &selection, varValMenuId,
  1040.                 HIGHLIGHT_OFF);
  1041.         interrupt_check (keyWas, varValMenuId);
  1042.     }
  1043.    }  /* end FOREVER loop */
  1044.  
  1045.  
  1046. } /* end varValMenu */
  1047.  
  1048.  
  1049. void varMenu (vtype, max_values)
  1050. long vtype;
  1051. long max_values;
  1052. {
  1053.    char         **menuText;
  1054. static char            *titleText[] = {
  1055.      "    name              type         record [dimension] variances     ",
  1056.      "",};
  1057.    struct window_struct *titleWindow;
  1058.    int  keyWas;
  1059.    long selection;
  1060.    /*int  j,k;*/
  1061.    long pageLines = numVars()+2;
  1062.  
  1063.    char banner[SCREEN_WIDTH+1];
  1064.  
  1065.    menuText = PTR_LIST_MALLOC( pageLines, char);
  1066.    FIXARRAY_MALLOC( menuText, pageLines, char,SCREEN_WIDTH +CDF_VAR_NAME_LEN+1);
  1067.    CLEAN_PAGE( menuText, pageLines, "");
  1068.  
  1069.     /* load the menuText with the variables list */
  1070.    writemVars( menuText);
  1071.  
  1072.    switch( vtype) {
  1073.     case VARDEF:
  1074.       sprintf(banner," %ld Variables (Select for attributes ) ",numVars());
  1075.       break;
  1076.     case VARVAL:
  1077.       sprintf(banner," %ld Variables (Select for data values) ",numVars());
  1078.       break;
  1079.    }
  1080.    WFL_popup_info (VARMEN_ROW, VARMEN_COL,
  1081.            SCREEN_HEIGHT,
  1082.            banner,
  1083.            titleText, &titleWindow);
  1084.  
  1085.    keyWas = KBM_EXIT +1;
  1086.    while (keyWas != KBM_EXIT)  {
  1087.       keyWas = WFL_popup_menu (VARMEN_ROW+2, VARMEN_COL,
  1088.                 VARMEN_HT, "", menuText,
  1089.                 &selection, varMenuId,
  1090.                 HIGHLIGHT);
  1091.  
  1092.       interrupt_check (keyWas, varMenuId);
  1093.  
  1094.       if (keyWas == KBM_SELECT && numVars() > 0)
  1095.      switch (vtype) {
  1096.         case VARDEF:
  1097.             varDefMenu (menu_bar_last_at_row (0) +2,
  1098.                 menu_bar_last_at_col (0) +2,
  1099.                 selection);
  1100.             break;
  1101.  
  1102.         case VARVAL:
  1103.             varValMenu (menu_bar_last_at_row (0) +2,
  1104.                 menu_bar_last_at_col (0) +22,
  1105.                 selection, max_values);
  1106.             break;
  1107.     } /* end switch */
  1108.    } /* end while */
  1109.    WFL_erase_window (titleWindow);
  1110.    WFL_delete_dyna_window (titleWindow);
  1111.    PTR_LIST_FREE( menuText, pageLines);
  1112. }  /* end varMenu */
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119. void attrEntriesMenu ( row, col, attrNum)
  1120. int   row;
  1121. int   col;
  1122. long  attrNum;
  1123. {
  1124. /* nov-1990, this menu changes to a selection-menu for entries. -dg. */
  1125.    char         **menuText;
  1126. static char name[CDF_ATTR_NAME_LEN+1] = "no-name";
  1127.    char label[CDF_ATTR_NAME_LEN +SCREEN_WIDTH+1];
  1128.    int keyWas;
  1129.    long selection;
  1130.    /*int j,k;*/
  1131.    long pageLines = maxAttrEntry( attrNum)+5;
  1132.  
  1133.    menuText = PTR_LIST_MALLOC( pageLines, char);
  1134.    FIXARRAY_MALLOC( menuText, pageLines, char, SCREEN_WIDTH+2);
  1135.    CLEAN_PAGE( menuText, pageLines, "");
  1136.  
  1137.     /* load the menuText */
  1138.    writemAttrEntries( menuText, attrNum);
  1139.  
  1140.    attribName(attrNum, name);
  1141.    sprintf (label,  "  %ld Entries for Attribute %s  ",
  1142.             maxAttrEntry( attrNum)+1, name);
  1143.    keyWas = KBM_EXIT +1;
  1144.    while (keyWas != KBM_EXIT)  {
  1145.     keyWas = WFL_popup_menu (row, col,
  1146.                 SCREEN_HEIGHT, label, menuText,
  1147.                 &selection, attrEntriesMenuId,
  1148.                 HIGHLIGHT);
  1149.  
  1150.     interrupt_check (keyWas, attrEntriesMenuId);
  1151.  
  1152.     if (keyWas == KBM_SELECT)  {
  1153.         attrEntryElemsMenu( menu_bar_last_at_row (0) +1,
  1154.                     menu_bar_last_at_col (0) +1,
  1155.                     attrNum, selection);
  1156.     }
  1157.    }
  1158.    PTR_LIST_FREE( menuText, pageLines);
  1159.  
  1160. } /* end attrEntriesMenu */
  1161.  
  1162.  
  1163. void attrMenu ()
  1164. {
  1165.    char         **menuText;
  1166.    static char        *titleText[] =
  1167.     {"     name          entries scope           ", "", };
  1168.    struct window_struct *titleWindow;
  1169.    int keyWas;
  1170.    long selection;
  1171.    /*int j,k;*/
  1172.    long pageLines = numAttrs()+5;
  1173.    char banner[SCREEN_WIDTH+1];
  1174.  
  1175.    menuText = PTR_LIST_MALLOC( pageLines, char);
  1176.    FIXARRAY_MALLOC( menuText, pageLines, char, SCREEN_WIDTH);
  1177.    CLEAN_PAGE( menuText, pageLines, "");
  1178.  
  1179.     /* load the attribute menu list */
  1180.    writemAttrs( menuText);
  1181.    sprintf (banner, " %ld Attributes ", numAttrs() );
  1182.  
  1183.    WFL_popup_info (ATTMEN_ROW, ATTMEN_COL, SCREEN_HEIGHT,
  1184.            banner, titleText, &titleWindow);
  1185.  
  1186.    keyWas = KBM_EXIT +1;
  1187.    while (keyWas != KBM_EXIT)  {
  1188.     keyWas = WFL_popup_menu (ATTMEN_ROW+2, ATTMEN_COL,
  1189.                 ATTMEN_HT,"", menuText,
  1190.                 &selection, attrMenuId,
  1191.                 HIGHLIGHT);
  1192.     interrupt_check (keyWas, attrMenuId);
  1193.  
  1194.     if (keyWas == KBM_SELECT  && numAttrs() > 0)  {
  1195.         attrEntriesMenu (menu_bar_last_at_row (0) +1,
  1196.                  menu_bar_last_at_col (0) +1,
  1197.                  selection);
  1198.     }
  1199.    }
  1200.    WFL_erase_window (titleWindow);
  1201.    WFL_delete_dyna_window (titleWindow);
  1202.    PTR_LIST_FREE( menuText, pageLines);
  1203.  
  1204. }  /* end attrMenu */
  1205.  
  1206.  
  1207. void browseMenu (max_values)
  1208. long         max_values;
  1209. {
  1210.    static char *browseList[]=
  1211.         {
  1212.         " Attribute Definitions ",
  1213.         " Variable Definitions  ",
  1214.         " Variable Values ",
  1215.         "",
  1216.         };
  1217.    int keyWas;
  1218.    long selection;
  1219.    /*int j,k;*/
  1220.      /*  cdf_id is static global integer */
  1221.  
  1222.    keyWas = KBM_EXIT +1;
  1223.  
  1224.    while (keyWas != KBM_EXIT)
  1225.      {
  1226.       keyWas = WFL_popup_menu ( 4, 59-COL_OFFSET,
  1227.                 SCREEN_WIDTH, " Browser ",
  1228.                 browseList,
  1229.                 &selection,
  1230.                 browseMenuId,
  1231.                 HIGHLIGHT);
  1232.  
  1233.      interrupt_check (keyWas, browseMenuId);
  1234.  
  1235.      if (keyWas == KBM_SELECT)
  1236.         switch (selection)    {
  1237.         case 0:
  1238.             attrMenu ();
  1239.             break;
  1240.         case 1:
  1241.             varMenu (VARDEF, max_values);
  1242.             break;
  1243.         case 2:
  1244.             varMenu (VARVAL, max_values);
  1245.             break;
  1246.         }  /* end select for browse Menu selection */
  1247.  
  1248.      }  /* end while keyWas != KBM_EXIT */
  1249. } /* end browseMenu */
  1250.  
  1251. #if defined(vms)
  1252. main (argc, argv) 
  1253. #else
  1254. void main (argc, argv)
  1255. #endif
  1256. int argc;
  1257. char *argv[];
  1258. {
  1259.    struct    main_struct    {
  1260.     char    *GLOBAL_cont;
  1261.     char    *MESS_MENU_cont;
  1262.    }     m;
  1263.    struct    window_struct    *onscreen_help_window;
  1264.  
  1265. static   char *onscreen_help[] =        {
  1266. " Kill window: CTRL-K    Select: RETURN    Explain: CTRL-I    main HELP:CTRL-L ",
  1267. "",
  1268.    };
  1269. static   char *filenotfound[] = {
  1270.       "  No CDFs in the directory, ",
  1271.       "  no such directory, or ",
  1272.       "  the directory is protected. ",
  1273.       "",
  1274.    };
  1275.  
  1276.    char   file_spec[MAXNAMELEN+1];
  1277.    char   path_spec[MAXNAMELEN+1];
  1278.    char **file_names = NULL;
  1279.    char **directory = NULL;
  1280.  
  1281.    char             **titlePage = NULL;
  1282.    struct window_struct     *cdfTitleWindow;
  1283.  
  1284.    char             **headerPage = NULL;
  1285.    struct window_struct     *cdfHeaderWindow;
  1286.  
  1287.    /*struct window_struct        *infoWindow;*/
  1288.    long     selection;
  1289.    long     max_values;
  1290.  
  1291.    int        nfiles,    keyWas,    program_status, /*scancode,*/ /*k,*/ resp;
  1292.    char         message[512], fileMenuBanner[512] /*, clearstring[512]*/ ;
  1293.    char **WFLlist;
  1294. QOP *qop;
  1295. static char *validQuals[] = { NULL };
  1296.  
  1297. /******************************************************************************
  1298. * Default directories (if none specified on command line).
  1299. ******************************************************************************/
  1300. #if defined(unix)
  1301. static char curr_dir[] = "./*.cdf" ;
  1302. #else
  1303. #if defined(__MSDOS__)
  1304. static char curr_dir[] = ".\\*.cdf";
  1305. #else
  1306. #if defined(vms)
  1307. static char curr_dir[] = "[]*.cdf";
  1308. #endif
  1309. #endif
  1310. #endif
  1311. /*char    temp[CDF_PATHNAME_LEN];*/
  1312.  
  1313. #if defined(unix)                        /* V1.3 */
  1314.   strcpy(path_spec, "./");   /* V2.1 should have this for default directory */
  1315. #endif
  1316.  
  1317. #if defined(vms)
  1318.   strcpy (path_spec, "[]");
  1319. #endif
  1320.  
  1321. #if defined(__MSDOS__)
  1322.  strcpy(path_spec,".");
  1323. #endif
  1324.  
  1325. /******************************************************************************
  1326. * Get qualifiers/options/parameters.
  1327. ******************************************************************************/
  1328.  
  1329. qop = Qop (argc, argv, validQuals, NULL);
  1330. if (qop == NULL) ExitBAD;
  1331.  
  1332. switch (qop->Nparms) {
  1333.   case 0:
  1334.     break;
  1335.   case 1:
  1336.     strcpy (path_spec, qop->parms[0]);
  1337.     break;
  1338.   default:
  1339.     printf ("Too many parameters.\n");
  1340.     ExitBAD;
  1341. }
  1342. #if NSSDC_STANDARD                        /* V1.4 */
  1343.    titlePage = PTR_LIST_MALLOC( TITLE_LINES, char);
  1344.    FIXARRAY_MALLOC( titlePage, TITLE_LINES, char, SCREEN_WIDTH);
  1345.    CLEAN_PAGE( titlePage, TITLE_LINES, "");
  1346. #endif
  1347.  
  1348.    headerPage = PTR_LIST_MALLOC( HEADER_LINES, char);
  1349.    FIXARRAY_MALLOC( headerPage, HEADER_LINES, char, SCREEN_WIDTH);
  1350.  
  1351.     /* these are used to clear message window the hard way */
  1352. /*   for (k=0; k<157; k++) clearstring[k] = ' ';
  1353.    clearstring[77] = '\n';
  1354.    clearstring[78] = '\r';
  1355.    clearstring[156] = '\0';*/
  1356.  
  1357.     /* Initialize the user interface */
  1358.    WFL_init ();
  1359.  
  1360.    /*
  1361.     *    This will put the bottom of the help box 3 lines above
  1362.     *    the screen bottom, flush left.
  1363.     */
  1364.    WFL_popup_info (SCREEN_HEIGHT -string_count(onscreen_help) -1, 1,
  1365.            SCREEN_HEIGHT,
  1366.         "",
  1367.         onscreen_help, &onscreen_help_window);
  1368.  
  1369.     /* Initialize message window */
  1370.    MESS_init ((struct mess_menu_struct **) &m.MESS_MENU_cont);
  1371.    MESS_draw ((struct mess_menu_struct * )m.MESS_MENU_cont);
  1372.    if (qop->Nparms != 1) {
  1373.      char bannerText[80+1];
  1374.      sprintf (bannerText, " CDFbrowse, CDF Version %ld.%ld.%ld distribution.",
  1375.           CDF_LIBRARY_VERSION, CDF_LIBRARY_RELEASE, CDF_LIBRARY_INCREMENT);
  1376.      MESS_display (bannerText, NOBEEP);
  1377.    }
  1378.  
  1379.     /* ----------------- End of all preliminaries ---------- */
  1380.    if (qop->Nparms != 1)
  1381.        program_status = select_directory (path_spec);
  1382.    else
  1383.       program_status = KBF_SELECT;
  1384.    if(strlen(path_spec) == 0)
  1385.       strcpy(file_spec, curr_dir);
  1386.    else
  1387.       BuildSearchSpec (path_spec, file_spec);
  1388.  
  1389.    while (program_status != KBF_EXIT)     {
  1390.     if (IsDir(path_spec))
  1391.      sprintf (message, " Browsing directory >> %s", path_spec);
  1392.      else
  1393.      sprintf (message, " Browsing CDF >> %s", path_spec);
  1394.  
  1395.      MESS_erase_display((struct mess_menu_struct *) m.MESS_MENU_cont);
  1396.      MESS_display (message, NOBEEP);
  1397.  
  1398.      nfiles = DirList (file_spec, &directory, &file_names);
  1399.  
  1400.  
  1401.      keyWas = KBM_EXIT +1;
  1402.      while (keyWas != KBM_EXIT)  {
  1403.  
  1404.     if (nfiles > 0)   {  /* if there are files, popup the list */
  1405.         sprintf (fileMenuBanner, "%3d CDFs ", nfiles);
  1406.         RemoveExtensions(nfiles, file_names);
  1407.         if(nfiles > 1)
  1408.            {
  1409.            BuildWFLlist (nfiles, file_names, &WFLlist);
  1410.            keyWas = WFL_popup_menu (1, 80, 10,
  1411.                    fileMenuBanner, WFLlist,
  1412.                   &selection, filesMenuId, HIGHLIGHT);
  1413.            FreeWFLlist (WFLlist);
  1414.            interrupt_check (keyWas, filesMenuId);
  1415.            }
  1416.         else
  1417.            {
  1418.            selection = 0;
  1419.            keyWas = KBM_SELECT;
  1420.            }
  1421.  
  1422.         if (keyWas == KBM_SELECT)    {
  1423.            CLEAN_PAGE( headerPage, HEADER_LINES, "");
  1424.      /*
  1425.      if only 1 cdf was entered, this will make the user enter another path_spec
  1426.      */
  1427.         if (nfiles == 1)keyWas = KBM_EXIT;
  1428.  
  1429.         cdf_id = openCDFtoBrowse (directory[selection],
  1430.                       file_names[selection],
  1431.                       headerPage, &max_values);
  1432.  
  1433.         switch( cdf_id) {
  1434.             case 0:    /* an error.  Show message and wait */
  1435.             WFL_popup_info (HEADER_ROW, HEADER_COL,
  1436.                 SCREEN_HEIGHT,
  1437.                 " no-can-do ",
  1438.                 headerPage, &cdfHeaderWindow);
  1439.       /* pause and show error, using dummy assign statement
  1440.                 warning message on PC */
  1441.             resp = getchar ();
  1442.             selection = resp;
  1443.             break;
  1444.  
  1445.             default:    /* a CDF is loaded; display the header */
  1446. #if NSSDC_STANDARD                        /* V1.4 */
  1447.             writemTitle (titlePage);
  1448.             WFL_popup_info (TITLE_ROW, TITLE_COL,
  1449.                    SCREEN_HEIGHT,
  1450.                    "",
  1451.                    titlePage, &cdfTitleWindow);
  1452. #endif
  1453.             WFL_popup_info (HEADER_ROW, HEADER_COL,
  1454.                     SCREEN_HEIGHT,
  1455.                     " Header ",
  1456.                     headerPage, &cdfHeaderWindow);
  1457.             browseMenu (max_values);
  1458. #if NSSDC_STANDARD                        /* V1.4 */
  1459.             WFL_erase_window (cdfTitleWindow);
  1460.             WFL_delete_dyna_window (cdfTitleWindow);
  1461. #endif
  1462.             cdfCloseQuit ();
  1463.             cdf_id = CDF_IS_CLOSED;
  1464.             break;
  1465.         }  /* end switch */
  1466.         WFL_erase_window (cdfHeaderWindow);
  1467.         WFL_delete_dyna_window (cdfHeaderWindow);
  1468.  
  1469.         }  /* end if KBM_SELECT a file name */
  1470.  
  1471.     } else {       /* number of files == 0 */
  1472.             /* No CDF files on the directory -- inform user */
  1473.       keyWas = WFL_popup_menu (12, 16, 12,
  1474.                   file_spec, filenotfound,
  1475.                 &selection, filenotfoundMenuId,
  1476.                         HIGHLIGHT_OFF);
  1477.       interrupt_check (keyWas, filenotfoundMenuId);
  1478.     }
  1479.      }  /* end while keyWas != KBM_EXIT */
  1480.  
  1481.       /* free the file_names list */
  1482.     if(file_names != NULL)free (file_names);
  1483.     if(directory != NULL) free (directory);
  1484.  
  1485.       /* Select the browse directory again for the next cycle */
  1486.      program_status = select_directory (path_spec);
  1487.      if(strlen(path_spec) == 0)
  1488.     strcpy(file_spec, curr_dir);
  1489.      else
  1490.     BuildSearchSpec (path_spec, file_spec);
  1491.  
  1492.    }   /* end while program_status != KBF_EXIT */
  1493.  
  1494. #if NSSDC_STANDARD                        /* V1.4 */
  1495.    PTR_LIST_FREE( titlePage, TITLE_LINES);
  1496. #endif
  1497.  
  1498.    PTR_LIST_FREE( headerPage, HEADER_LINES);
  1499.  
  1500.    exitProgram();
  1501. }  /* end main */
  1502.